var oNowTime = new Date().getTime();
//document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"{CSS_PATH}mz/themes.css?oNowTime="+time+"\"/>");
//document.write("<scr" + "ipt src='url.js?time="+oNowTime+"'></scr" + "ipt>");
//console.log(oNowTime)
window.onload = function(){

  Vue.component('headerShow',headerShow);
  Vue.component('footerShow',footerShow);

  Vue.use(VueRouter);
  const router = new VueRouter({
    //mode: 'history', //切换路径模式，变成history模式  消除 #
    routes: [
      { path: '/index/', component: indexContainer },
      { path: '/about/', component: aboutContainer },
      { path: '/product/', component: productContainer ,children: [
        { path: '/product/:index/', component: productRight },
        { path: '/product/:index/', component: productRight },
        { path: '/productDetail/:index/:innerIndex', component: productDetail }
      ]},
      { path: '/news/', component: newsContainer ,children: [
        { path: '/newsDetail/:index/:innerIndex', component: newsDetail }
      ]},
      { path: '/dowmload/', component: downloadContainer },
      { path: '/contact/', component: contactContainer },

      { path: "/",redirect: "/index" },
      { path: "*",redirect: "/index" }  //404重定向
    ]
  });

  Vue.use(VueLazyload, {
    //  http://www.sohu.com/a/211060254_114949
    error: 'http://5b0988e595225.cdn.sohucs.com/images/20171217/850e5b4b337f406a9d1e5bfd768d1da6.gif',   //这个是请求失败后显示的图片
    loading: 'http://upload.chinaz.com/2015/0426/1430007062684.gif',       //这个是加载的loading过渡效果
    try: 2 // 这个是加载图片数量
  });


  //单一事件中心管理组件通信 准备一个空的实例对象
  var Event = new Vue();

  var vm = new Vue({
    el: '#app',
    router,
    data: {
      product:{
        data:[]
      },
      news:{
        data:[]
      },
    },
    components:{
      indexContainer,
      aboutContainer,
      productContainer,
      newsContainer,
      downloadContainer,
      contactContainer,
    },
    mounted: function() {
        this.$nextTick(function() {
            this.getProductData();
            this.getNewsData();
        });
    },

    methods: {
        getProductData(){
            //axios.get('http://localhost/cmsya_com/libs/study/vuejs/url/netUrl.json')
            axios.get('data/product.json')
              .then(function (res) {
                //console.log(res.data.result);
                  this.product.data = res.data.result;
                  //console.log(this.product.list[0].productList[0].name);
              }.bind(this)).catch(
                  function (err) {
                      console.log(err);
                  }
              )
        },
        getNewsData(){
            //axios.get('http://localhost/cmsya_com/libs/study/vuejs/url/netUrl.json')
            axios.get('data/news.json')
              .then(function (res) {
                //console.log(res.data.result);
                  this.news.data = res.data.result;
              }.bind(this)).catch(
                  function (err) {
                      console.log(err);
                  }
              )
        }
    },
  });

}